home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / daolibb / mainfrm.cpp < prev    next >
C/C++ Source or Header  |  1998-12-30  |  3KB  |  133 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DaoSample.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMainFrame
  17.  
  18. IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
  19.  
  20. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  21.     //{{AFX_MSG_MAP(CMainFrame)
  22.         // NOTE - the ClassWizard will add and remove mapping macros here.
  23.         //    DO NOT EDIT what you see in these blocks of generated code !
  24.     ON_WM_CREATE()
  25.     ON_WM_SETFOCUS()
  26.     //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28.  
  29. static UINT indicators[] =
  30. {
  31.     ID_SEPARATOR,           // status line indicator
  32.     ID_INDICATOR_CAPS,
  33.     ID_INDICATOR_NUM,
  34.     ID_INDICATOR_SCRL,
  35. };
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CMainFrame construction/destruction
  39.  
  40. CMainFrame::CMainFrame()
  41. {
  42.     // TODO: add member initialization code here
  43.     
  44. }
  45.  
  46. CMainFrame::~CMainFrame()
  47. {
  48. }
  49.  
  50. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  51. {
  52.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  53.         return -1;
  54.     // create a view to occupy the client area of the frame
  55.     if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
  56.         CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  57.     {
  58.         TRACE0("Failed to create view window\n");
  59.         return -1;
  60.     }
  61.     
  62.     if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  63.         | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  64.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  65.     {
  66.         TRACE0("Failed to create toolbar\n");
  67.         return -1;      // fail to create
  68.     }
  69.  
  70.     if (!m_wndStatusBar.Create(this) ||
  71.         !m_wndStatusBar.SetIndicators(indicators,
  72.           sizeof(indicators)/sizeof(UINT)))
  73.     {
  74.         TRACE0("Failed to create status bar\n");
  75.         return -1;      // fail to create
  76.     }
  77.  
  78.     // TODO: Delete these three lines if you don't want the toolbar to
  79.     //  be dockable
  80.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  81.     EnableDocking(CBRS_ALIGN_ANY);
  82.     DockControlBar(&m_wndToolBar);
  83.  
  84.     return 0;
  85. }
  86.  
  87. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  88. {
  89.     if( !CFrameWnd::PreCreateWindow(cs) )
  90.         return FALSE;
  91.     // TODO: Modify the Window class or styles here by modifying
  92.     //  the CREATESTRUCT cs
  93.  
  94.     cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  95.     cs.lpszClass = AfxRegisterWndClass(0);
  96.     return TRUE;
  97. }
  98.  
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CMainFrame diagnostics
  101.  
  102. #ifdef _DEBUG
  103. void CMainFrame::AssertValid() const
  104. {
  105.     CFrameWnd::AssertValid();
  106. }
  107.  
  108. void CMainFrame::Dump(CDumpContext& dc) const
  109. {
  110.     CFrameWnd::Dump(dc);
  111. }
  112.  
  113. #endif //_DEBUG
  114.  
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CMainFrame message handlers
  117. void CMainFrame::OnSetFocus(CWnd* pOldWnd)
  118. {
  119.     // forward focus to the view window
  120.     m_wndView.SetFocus();
  121. }
  122.  
  123. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  124. {
  125.     // let the view have first crack at the command
  126.     if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  127.         return TRUE;
  128.  
  129.     // otherwise, do default handling
  130.     return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  131. }
  132.  
  133.